package chapter2.No2_2_synchronized同步语句块.p锁对象的改变.demo1;

/**
 * Created by Administrator on 2016/11/15.
 */
public class MyService {

    String lock = "123";

    public void methodA() {

        synchronized (lock) {
            try {
                System.out.println(Thread.currentThread().getName() +" 线程进入！");
                lock = "456";
                Thread.sleep(2000);
                System.out.println(Thread.currentThread().getName() +" 线程退出！");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

}
